package com.hotau.setting;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.hotau.HotauActivity;
import com.hotau.R;
import com.hotau.framework.FooterVisible;
import com.hotau.framework.IndexFragment;

/**
 * 系统设置
 * 
 * @author hanshengliang
 * @data 2011-12-10
 * @version 1.0
 *          <ul>
 *          <li>1.0 创建</li>
 *          </ul>
 */
public class SettingFragment extends Fragment implements OnClickListener,
		FooterVisible, IndexFragment {

	public static final String TAG = "SettingFragment";
	private LinearLayout setting_btn_notify = null;
	private LinearLayout setting_btn_help = null;
	private LinearLayout setting_btn_soft = null;

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onActivityCreated(savedInstanceState);
		initAllWidget();
		initAllEvent();
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		return inflater.inflate(R.layout.setting_more_view, container, false);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.setting_notify_linearlayout:
			HotauActivity notifyActivity = (HotauActivity) getActivity();
			notifyActivity.pushFragment(
					getString(R.string.setting_notify_title),
					new SettingNotifyFragment());
			break;
		case R.id.setting_help_linearlayout:
			HotauActivity helpActivity = (HotauActivity) getActivity();
			helpActivity.pushFragment(getString(R.string.setting_help_title),
					new SettingHelpFragment());
			break;
		case R.id.setting_soft_linearlayout:
			HotauActivity aboutActivity = (HotauActivity) getActivity();
			aboutActivity.pushFragment(getString(R.string.setting_soft_title),
					new SettingAboutFragment());
			break;
		default:
			break;
		}
	}

	/**
	 * 初始化所有控件
	 */
	public void initAllWidget() {
		setting_btn_notify = (LinearLayout) getActivity().findViewById(
				R.id.setting_notify_linearlayout);
		setting_btn_help = (LinearLayout) getActivity().findViewById(
				R.id.setting_help_linearlayout);
		setting_btn_soft = (LinearLayout) getActivity().findViewById(
				R.id.setting_soft_linearlayout);
	}

	/**
	 * 初始化所有事件
	 */
	public void initAllEvent() {
		setting_btn_notify.setOnClickListener(this);
		setting_btn_help.setOnClickListener(this);
		setting_btn_soft.setOnClickListener(this);
	}
}
